package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Comment;
import com.dragon.repository.entity.DailyLogs;
import com.dragon.repository.entity.OtherFile;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DailyLogsDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "日报标题")
    private String dailyTitle;

    @ApiModelProperty(value = "今日总结")
    private String summary;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "是否删除0未删除1删除")
    private Integer deleted;

    @ApiModelProperty(value = "明天工作计划")
    private String workPlan;

    @ApiModelProperty(value = "待处理的问题")
    private String pendingIssues;

    @ApiModelProperty(value = "地址")
    private String address;

    @ApiModelProperty(value = "类型 1日报 2周报 3月报")
    private Integer type;

    @ApiModelProperty(value = "汇报人id")
    private Integer reporterId;

    @ApiModelProperty(value = "汇报人名称")
    private String reporterName;

    @ApiModelProperty(value = "用户名称")
    private String username;

    @ApiModelProperty(value = "用户头像图片")
    private String userImg;

    @ApiModelProperty(value = "附件")
    List<OtherFile> otherFiles;

    @ApiModelProperty(value = "评论")
    List<Comment> comments;


    public DailyLogsDTO() {}

    public DailyLogsDTO(DailyLogs entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static DailyLogsDTO convert(DailyLogs entity) {
        return new DailyLogsDTO(entity);
    }

    public static List<DailyLogsDTO> convertList(List<DailyLogs> list) {
        List<DailyLogsDTO> resultList = new ArrayList<>();
        for (DailyLogs entity : list) {
            resultList.add(new DailyLogsDTO(entity));
        }
        return resultList;
    }}
